package com.cdl.library.util;

public class EventClick {

    private long lastTime;
    private int clickCount;
    private final long DELAY = 400L;

    public boolean isCountClick(int count) {
        if (count < 1) {
            return false;
        }
        clickCount++;
        boolean click = false;
        long current = System.currentTimeMillis();
        if (current - lastTime < DELAY) {
            //System.out.println("bbbbbbbbbbbb---------->" + (clickCount + 1) + " " + (clickCount + 1 == count));
            if (clickCount + 1 == count) {
                click = true;
            }
        } else {
            clickCount = 0;
            if (count == 1) {
                click = true;
            }
        }
        lastTime = current;
        return click;
    }

    private long oneLastTime;
    private long oneDelay = 800;

    public boolean isOneClick() {
        long current = System.currentTimeMillis();
        if (current - oneLastTime > oneDelay) {
            oneLastTime = current;
            return true;
        }
        oneLastTime = current;
        return false;
    }

    public void setOneDelay(long delay) {
        this.oneDelay = delay;
    }
}
